package net.sk.china.city.domain.dto.user;

import net.sk.china.city.domain.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class UserDetailDTO {
    @ApiModelProperty(value = "主键")
    private Long pkId;

    @ApiModelProperty(value = "电话号码")
    private String phone;

    @ApiModelProperty(value = "姓名")
    private String realName;

    @ApiModelProperty(value = "昵称")
    private String nickName;

    @ApiModelProperty(value = "角色")
    private Integer role;

    @ApiModelProperty(value = "账号注册时间")
    private LocalDateTime registerDatetime;

    @ApiModelProperty(value = "加入志愿者时间")
    private LocalDateTime joinDatetime;

    @ApiModelProperty(value = "工作单位，用户自己填")
    private String company;

    @ApiModelProperty(value = "政治身份，系统内常量")
    private Integer politicalIdentityId;

    @ApiModelProperty(value = "加入志愿说明")
    private String joinDescription;

    @ApiModelProperty(value = "账号")
    private String account;

    @ApiModelProperty(value = "联系地址")
    private String contactAddress;

    @ApiModelProperty(value = "头像url")
    private String avatar;

    @ApiModelProperty(value = "积分")
    private BigDecimal point;

    @ApiModelProperty(value = "工时")
    private BigDecimal workHours;

    @ApiModelProperty(value = "微信的openid，绑定微信时写入")
    private String openId;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "生日")
    private LocalDate birthDate;

    @ApiModelProperty(value = "性别，0:男 1:女 2：未知")
    private Integer sex;

    @ApiModelProperty(value = "特长")
    private String forte;

    @ApiModelProperty(value = "电信运营商")
    private Integer isp;

    @ApiModelProperty(value = "服务人次")
    private Integer servCount;

    @ApiModelProperty(value = "身份证号码")
    private String idNumber;

    @ApiModelProperty(value = "网格地区")
    private String regionIdList;

    @ApiModelProperty(value = "管理队伍id")
    private TeamPairDTO managedTeam;

    private List<TeamPairDTO> teamIdNamePairList;

    public static UserDetailDTO from(User user) {
        UserDetailDTO userDetailDTO = new UserDetailDTO();
        userDetailDTO.setPkId(user.getPkId());
        userDetailDTO.setPhone(user.getPhone());
        userDetailDTO.setRealName(user.getRealName());
        userDetailDTO.setNickName(user.getNickName());
        userDetailDTO.setRole(user.getRole());
        userDetailDTO.setRegisterDatetime(user.getRegisterDatetime());
        userDetailDTO.setJoinDatetime(user.getJoinDatetime());
        userDetailDTO.setCompany(user.getCompany());
        userDetailDTO.setPoliticalIdentityId(user.getPoliticalIdentityId());
        userDetailDTO.setJoinDescription(user.getJoinDescription());
        userDetailDTO.setAccount(user.getAccount());
        userDetailDTO.setContactAddress(user.getContactAddress());
        userDetailDTO.setAvatar(user.getAvatar());
        userDetailDTO.setPoint(user.getPoint());
        userDetailDTO.setWorkHours(user.getWorkHours());
        userDetailDTO.setOpenId(user.getOpenId());
        userDetailDTO.setBirthDate(user.getBirthDate());
        userDetailDTO.setSex(user.getSex());
        userDetailDTO.setForte(user.getForte());
        userDetailDTO.setIsp(user.getIsp());
        userDetailDTO.setServCount(user.getServCount());
        userDetailDTO.setIdNumber(user.getIdNumber());
        userDetailDTO.setRegionIdList(user.getRegionIdList());
        return userDetailDTO;
    }
}
